
#ifndef  SPINLOCK_H
#define  SPINLOCK_H

#include <pthread.h>

struct spinlock {
  const char * name;
  pthread_spinlock_t  locked;
  volatile int is_locked;
};

void initlock(struct spinlock *lk, char *name);
void acquire(struct spinlock * lk);
void release(struct spinlock * lk);
int holding(struct spinlock * lk);


void destroylock(struct spinlock * lk);

#endif   /* SPINLOCK_H */
